using System;
using Science.Mathematics;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter07
{
	/// <summary>
	/// Example05: Work Done by the Sun on Probe.
	/// The interplanetary probe show in Figure 7.9a is 
	/// attracted to the Sun by a force given by
	/// F = -1.3 \times 10^{22} / x^2
	/// in SI units, where x is the Sun-probe separation distance.
	/// Graphically and analytically determine how much work is 
	/// done by the Sun on the probe-Sun separation changes 
	/// from 1.5 \times 10^{11} m to  2.3 \times 10^{11} m
	/// W = -3.0 \times 10^{10} J
	/// </summary>
	public class Example05
	{
		public Example05()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Vector.FunctionOfPosition func = new L.Vector.FunctionOfPosition(FvsX);
			L.Force f = new L.Force();
            f.VectorFunctionOfPosition = func;
			L.Line.Parameterization pf = new L.Line.Parameterization(XvsT);
			L.Line p = new L.Line(pf);
			p.ParameterStartValue = 1.5*Math.Pow(10.0,11.0);
			p.ParameterEndValue = 2.3*Math.Pow(10.0,11.0);
			L.Work w = new L.Work(f,p);
			result = Convert.ToString(w.J);
		}
		private L.Vector FvsX(L.Position x)
		{
			L.Vector force = new L.Vector();
			force.X = -1.3*Math.Pow(10.0,22.0)/x.X/x.X;
			return force;
		}
		private L.Position XvsT(double t)
		{
			L.Position x = new L.Position();
			x.X = t;
			return x;
		}
	}
}
